app.controller('shopWechatConfigCtrl',['$scope','$state','$timeout','shopWechatConfigService','toaster',function($scope,$state,$timeout,shopWechatConfigService,toaster){

    //查询店铺信息
    $scope.findinfo=function(){
        shopWechatConfigService.getWechatConfig($scope).then(function (result) {
            switch (result.status){
                case 200:
                    $scope.wechat=result.data;
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break;
            }
        })
    }

    $scope.findinfo();

    $scope.editWechatConfig = function(){
        shopWechatConfigService.updateWechatConfig($scope).then(function(result){
            switch (result.status){
                case 200:
                    toaster.pop('success', "提示", "操作成功");
                    //$state.go("app.wechatConfig");
                    break;
                case 644:
                    toaster.pop('error', "操作失败", "该店铺已存在");
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break
            }
        });
    }


}])